In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
A Byteotian ant is walking along the edges of ABCDEFGH cube:
It tries to find out, in how many ways it can go from one given vertex, to another given vertex, walking along exactly edges (when the ant enters an edge, it will not turn back and will finally reach the second end of this edge). If the ant goes through some edge times, we count this edge times. The ant would like to have interesting routes, that is if the ant is in some vertex, it would like to leave this vertex using an edge other than the edge recently used to enter this vertex (i.e. it want not to use the same edge twice in a row).
Our ant is not so smart, because it can only count using integers from to , for some , so you should compute the result modulo .
Write a program which:
The first line of the standard input contains two capital English letters and (, ), separated by a single space. The two letters denote the starting and ending vertex of the ant's route respectively. The second line contains two integers and (, ), separated by a single space.
Exactly one integer is to be written on the standard output. This integer is the number of interesting routes from the vertex to the vertex , containing exactly edges, modulo .
For the input data:
A B 3 100
the correct result is:
2
Task author: Jakub Radoszewski.